package com.cy.myblog.action.menu;

import com.cy.myblog.action.BaseAction;
import com.cy.myblog.model.Tmenu;
import com.cy.myblog.pageModel.Json;
import com.cy.myblog.service.MenuServiceI;
import com.cy.myblog.service.RepairServiceI;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2015/7/13.
 */
@Controller("menuAction")
@Scope("prototype")
public class MenuAction extends BaseAction{

    private String id;
    private String name;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    private Json json = null;
    private Tmenu firstMenu;
    private MenuServiceI menuService;
    private RepairServiceI repairService;

    public Json getJson() {
        return json;
    }

    public void setJson(Json json) {
        this.json = json;
    }

    public Tmenu getFirstMenu() {
        return firstMenu;
    }

    public void setFirstMenu(Tmenu firstMenu) {
        this.firstMenu = firstMenu;
    }

    @Resource(name = "repairService")
    public void setRepairService(RepairServiceI repairService) {
        this.repairService = repairService;
    }

    @Resource(name = "menuSerivce")
    public void setMenuService(MenuServiceI menuService) {
        this.menuService = menuService;
    }

    public String repair(){
        json = new Json();
        repairService.repair();
        json.setMsg("数据初始化成功!");
        json.setRedirectPage("/jsp/backend/back_index.jsp");
        return "message";
    }

    public void queryAll(){
        System.out.println(id);
        System.out.println(name);
        firstMenu = menuService.getById("0");
        writeJson(firstMenu);
    }
}